﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Passwords.Biz
{
    public class CategorizedPassword
    {
        public Password Password { get; private set; }
        public Category Category { get; private set; }

        public int CategoryId { get { return Category.Id; } }

        public CategorizedPassword(Category c, Password p)
            : base()
        {
            this.Password = p;
            this.Category = c;
        }

        public override bool Equals(object obj)
        {
            CategorizedPassword pi = obj as CategorizedPassword;
            if (pi == null) return false;
            return (pi.CategoryId == CategoryId && pi.Password.Id == Password.Id);
        }

        public override int GetHashCode()
        {
            return CategoryId ^ Password.Id.GetHashCode();
        }
    }
}
